<template>
	<!-- banner -->
	<div class="re banner" v-if="bannerSwiperData.show && banner.length>0">
	  <swiper :options="bannerSwiperConfig">
	    <swiper-slide class="swiper-slide" v-for="(item,index) in banner" :key="index">
	      <div class="link cur" @click="indexLink(item)" :style="{backgroundImage:'url('+imgUrl+item.attachment.path+')'}"></div>
	    </swiper-slide>
	  </swiper>
	  <swiperBtn :swiperData = 'bannerSwiperData' />
	</div>
</template>
<script>
import swiperBtn from '@/components/swiperBtn.vue' //轮播的翻页 + 左右按钮
import {swiperConfig,ajax} from '@/utils/js.js'
import {homeBanner} from '@/services/api.js'
export default{
	data(){
		return{
			banner:[],
			bannerSwiperConfig:'',//banner-轮播配置,
			bannerSwiperData:{show:false}, //banner-轮播参数
			imgUrl:this.$store.state.imgUrl,	//图片前缀
		}
	},
	components:{
	  swiperBtn
	},
	methods:{
		content(){
			// 大图
			ajax(this,homeBanner,{},res=>{
				// console.log(res.data)
				this.banner = res.data

			})
		}
	},
	mounted(){
	  let bannerData = {
	    view:1,
	    show:true,
	    autoplayLast:true,
	    fy:'bannerdot'
	  }
	  swiperConfig(this,bannerData,'bannerSwiperConfig','bannerSwiperData',index=>{})
	  this.content()
	},
	watch:{
	  '$i18n.locale'(){
	    this.content()
	  },
	},
}
</script>
<style scoped="scoped">

</style>
